package backpage.model;

import java.io.File;

public class DeleteHandler {
	public static final DeleteHandler instance = new DeleteHandler();
	
	public void deleteItems( String[] IDs, String webRoot){
		if( IDs != null )
			for( int i = 0; i < IDs.length; i++){
				try{
					int id = Integer.parseInt(IDs[i]);
					String fullPath = DBAccessor.Instance.getResFullPathByID(id);
					if( fullPath != null ){
						File file = new File( webRoot + DBAccessor.Instance.getResFullPathByID(id) );
						if( file != null ) file.delete();
					}
					DBAccessor.Instance.deleteResByID(id);
				}catch (NumberFormatException e){
					System.err.println(e);
				}
			}
	}
}
